<?php
include_once "../../../../common.php";
?>
<table width="100%;">
	<tr>
		<td width="40%">
			Firstname
		</td>
		<td width="10px">:</td>
		<td>
			<input type="text" id="Firstname" />
		</td>
	</tr>
	<tr>
		<td>
			Initials
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Initials" />
		</td>
	</tr>
	<tr>
		<td>
			Surname
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Surname" />
		</td>
	</tr>
	<tr>
		<td>
			Sex
		</td>
		<td>:</td>
		<td>
			<select id="Sex">
				<option value="">UNKNOWN</option>
			<?php
			$sub_query = "SELECT * FROM Sexes ORDER BY Name";
			$sub_result = $_MySQL->runQuery($sub_query);
			while($sub_row = mysql_fetch_assoc($sub_result))
			{
				?>
				<option value="<?=$sub_row['ID'];?>"><?=$sub_row['Name'];?></option>
				<?php
			}
			?>
			</select>
		</td>
	</tr>
	<tr>
		<td>
			Insertion
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Insertion" />
		</td>
	</tr>
	<tr>
		<td>
			Function
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Function" />
		</td>
	</tr>
	<tr>
		<td>
			Email
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Email" />
		</td>
	</tr>
	<tr>
		<td>
			Mobile
		</td>
		<td>:</td>
		<td>
			<input type="text" id="Mobile" />
		</td>
	</tr>
	<tr>
		<td>
			FirstNameBasis
		</td>
		<td>:</td>
		<td>
			<input type="checkbox" id="FirstNameBasis" value="1" />
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<input type="button" value=" Toevoegen " onClick="javascript: addContactpersoon()" /> 
		</td>
	</tr>
</table>
<script>
	function addContactpersoon()
	{
		var url = 'factory/addContactpersoon.php';
		var FirstNameBasis = parseInt($('#FirstNameBasis:checked').val());
		var Mobile = $('#Mobile').val();
		var Firstname = $('#Firstname').val();
		var Initials = $('#Initials').val();
		var Surname = $('#Surname').val();
		var Insertion = $('#Insertion').val();
		var Function = $('#Function').val();
		var Email = $('#Email').val();
		$.post(
				url,
				{
					ID:'<?=$_GET['id'];?>',
					FirstNameBasis:FirstNameBasis,
					Mobile:Mobile,
					Firstname:Firstname,
					Initials:Initials,
					Surname:Surname,
					Insertion:Insertion,
					Function:Function,
					Email:Email
				},
				function(data)
				{
					if(data == 'succes')
					{
						updateElement('KlantenContactpersonen');
				 	 	$(".popup").dialog('destroy');
					}
					else alert(data);
				}
		);
	}
</script>